/*
 * @copyright: Huang Ding
 * @Author: ding-cx
 * @Date: 2021-02-02 15:00:33
 * @LastEditors: ding
 * @LastEditTime: 2022-11-07 09:57:15
 * @Description: file content
 */
import { EggAppConfig, EggAppInfo, PowerPartial } from "egg";

// @ts-ignore
export default (appInfo: EggAppInfo) => {
	const config = {} as PowerPartial<EggAppConfig>;

	config.customLoader = {
		codo: {
			directory: "app/codo",
			inject: "app",
			loadunit: true,

			ignore: ["**/*.base.js", "**/*.base.ts", "**/*.d.ts"],
		},
	};

	/** 中控在线消费接口中间件配置 */
	config.zkOnlineConsume = {
		enable: true,
		// 在线消费设备接口列表，将会被中间件拦截，单独处理
		match: ["/token.do", "/posIDFaceConsumeDevice.do"],
	};

	config.codo = {
		/** 外部可注入的业务数据管理器，用于获取业务数据  */
		codoDataManager: null,
		/** 中控在线消费接口配置 */
		onlineConsumeDeviceHandler: async (_ctx: any) => {
			throw new Error("place define your onlineConsumeDeviceHandler handler function on app.config.codo");
		},
	};

	config.zk = {};
	return {
		...config,
	};
};
